#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->pushButton_doge->setIcon(QIcon(":/image/doge.png"));
    ui->pushButton_doge->setIconSize({100, 100});

    ui->pushButton_up->setIcon(QIcon(":/image/up.png"));
    //ui->pushButton_up->setShortcut(QKeySequence("W"));
    ui->pushButton_up->setShortcut(Qt::Key::Key_W);
    ui->pushButton_up->setAutoRepeat(true);

    ui->pushButton_down->setIcon(QIcon(":/image/down.png"));
    //ui->pushButton_down->setShortcut(QKeySequence("S"));
    ui->pushButton_down->setShortcut(Qt::Key::Key_S);

    ui->pushButton_left->setIcon(QIcon(":/image/left.png"));
    //ui->pushButton_left->setShortcut(QKeySequence("A"));
    ui->pushButton_left->setShortcut(Qt::Key::Key_A);

    ui->pushButton_right->setIcon(QIcon(":/image/right.png"));
    //ui->pushButton_right->setShortcut(QKeySequence("D"));
    ui->pushButton_right->setShortcut(Qt::Key::Key_D);

}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_up_clicked()
{
    QRect rect = ui->pushButton_doge->geometry();
    ui->pushButton_doge->setGeometry(rect.x(), rect.y() - 5, rect.width(), rect.height());
}

void Widget::on_pushButton_down_clicked()
{
    QRect rect = ui->pushButton_doge->geometry();
    ui->pushButton_doge->setGeometry(rect.x(), rect.y() + 5, rect.width(), rect.height());
}

void Widget::on_pushButton_left_clicked()
{
    QRect rect = ui->pushButton_doge->geometry();
    ui->pushButton_doge->setGeometry(rect.x() - 5, rect.y(), rect.width(), rect.height());
}

void Widget::on_pushButton_right_clicked()
{
    QRect rect = ui->pushButton_doge->geometry();
    ui->pushButton_doge->setGeometry(rect.x() + 5, rect.y(), rect.width(), rect.height());
}
